
#include "LoadingBarTestLayer.h"
#include "CocosGUI.h"
#include "utils/LocalStringUtil.h"
#include "utils/FunctionLifeCrycle.h"

USING_NS_CC;


bool LoadingBarTestLayer::init()
{
	FUNCTION_LIFE_CRYCLE
	auto winSize =  Director::getInstance()->getWinSize();
	auto text = ui::Text::create(LocalStringUtil::getInstance()->getLocalString("login"),"Courier new",20);
	text->ignoreContentAdaptWithSize(false);
	text->setContentSize(Size(180,240));
	text->setColor(Color3B(255,153,18));
	text->setPosition(Vec2(winSize.width/2,winSize.height/2));
	this->addChild(text);

	ui::Text* text1 = ui::Text::create("Text can line wrap","AmericanTypewriter",32);
	text1->ignoreContentAdaptWithSize(false);
	text1->setContentSize(Size(280, 150));
	text1->setTextHorizontalAlignment(TextHAlignment::CENTER);
	text1->setPosition(Vec2(winSize.width / 2.0f, winSize.height / 2.0f - text->getContentSize().height / 8.0f));
	this->addChild(text1);

	loadingBar = ui::LoadingBar::create("sliderProgress.png",100);
	loadingBar->setPosition(Vec2(winSize.width/2,winSize.height/3));
	loadingBar->setPercent(20);
	this->addChild(loadingBar);
	scheduleUpdate();
	return true;
}

int i = 0;
void LoadingBarTestLayer::update(float delta)
{
	if(i > 100){
		i = 0;
	}
	loadingBar->setPercent(i);
	i++;
}
